﻿<?php
/**
 * Created by PhpStorm.
 * User: 子不语
 * Date: 2016/7/4
 * Time: 14:15
 */
$id = intval($_GET['id']) ?: 0;
if ($id > 0) {
    switch ($id) {
        case 1:
            echo info('gamecatchluck.php?key=catch_result_beijing');
            break;
        case 2:
            echo info('gameopenluck.php?key=kj_beijingtype_result');
            break;
        case 3://pk
            echo info('gamecatchpk.php?key=catch_result_pk');
            break;
        case 4://pk
            echo info('gameopenpk.php?key=kj_pktype_result');
            break;
    }
    exit();
}
function info($url)
{
    $html = file_get_contents('http://' . $_SERVER['SERVER_NAME'] . '/dscaiji/' . $url);
    $json = json_decode($html, true);
    $t = strtotime($json['nexttime']) - time() - 2;
    $t = $t > 0 ? $t : 0;
	if(!$json['nexttime'])$t=20;
    $eco = '
<!doctype html><html><head><meta http-equiv="refresh" content="' . $t . '" />
<script type="text/javascript">var t=' . $t . ';function showtime(){document.getElementById("t").innerHTML=t--;}setInterval(showtime,1000);</script><style>.red{color:#f00;}</style></head>
<body>
结果:' . $json['msg'] . ';等待刷新<span id="t" class="red">' . $t . '</span>秒<br>json:' . $html . '</body></html>';
    return $eco;

}

?>
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>采集</title>
    <style>
        th {background-color: #00a317;color:#fff;font-weight:normal;}
        iframe {width: 100%;border:none;height: 82px;}
        table{border:none;border-right: #00c325 1px solid;border-top: #00c325 1px solid;}
        td,th{border-width: 1px;border-bottom: #00c325 1px solid;}
    </style>
    <meta http-equiv="refresh" content="120" />
</head>
<body>
<table width="1024" border="0" cellspacing="0" cellpadding="0">
    <tbody>
    <tr>
        <th scope="row">北京快乐8        </td>
        <td id="t1">    <iframe id="g_4" name="g_4" src="?id=1"></iframe>           </td>
    </tr>
    <tr>
        <th scope="row">北京快乐8        </td>
        <td>            <iframe id="g_4" name="g_4" src="?id=2"></iframe>        </td>
    </tr>

    <tr>
        <th scope="row">北京PK        </td>
        <td>            <iframe id="g_5" name="g_5" src="?id=3"></iframe>        </td>
    </tr>
    <tr>
        <th scope="row">北京PK        </td>
        <td>            <iframe id="g_5" name="g_5" src="?id=4"></iframe>        </td>
    </tr>
    </tbody>
</table>

</body>
</html>
